package com.ssy.lingxi.after.sale.model.constant;

import com.ssy.lingxi.after.sale.model.vo.response.DropdownItemVO;
import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 *  退货原因枚举
 * @author ds
 * @date 2021/10/11
 * @version 2.0.0
 */
public enum ReturnGoodsReasonEnum {

    REASON_1(1, "卖家发错货"),
    REASON_2(2, "商品与描述不符"),
    REASON_3(3, "误购（不喜欢/大小不合适）"),
    REASON_4(4, "质量问题");

    private final Integer code;
    private final String message;

    ReturnGoodsReasonEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static List<DropdownItemVO> toDropdownItems() {
        return Arrays.stream(ReturnGoodsReasonEnum.values()).sorted(Comparator.comparingInt(ReturnGoodsReasonEnum::getCode)).map(e -> new DropdownItemVO(e.getCode(), e.getMessage())).collect(Collectors.toList());
    }
}
